import os
import cv2
import numpy as np

img1 = cv2.imread(r'save_images\save_images4\0523\view_00\image_back.png', cv2.IMREAD_UNCHANGED)
img2 = cv2.imread(r'save_images\save_images4\0523\view_00\T_normal_back.png', cv2.IMREAD_UNCHANGED)

img1_rgb = cv2.cvtColor(img1, cv2.COLOR_BGRA2BGR)
img2_rgb = cv2.cvtColor(img2, cv2.COLOR_BGRA2BGR)

img1_mask = img1[:, :, 3] > 0
img2_mask = img2[:, :, 3] > 0

gap = np.sum(img1_mask != img2_mask)
print(f"gap: {gap}")

res1 = np.zeros_like(img1_rgb)
res2 = np.zeros_like(img2_rgb)
res1[..., 2][img1_mask] = 255
res2[..., 1][img2_mask] = 255

res = cv2.addWeighted(res1, 0.5, res2, 0.5, 0)

cv2.imshow('img1', img1_rgb)
cv2.imshow('img2', img2_rgb)
cv2.imshow('img1_mask', img1_mask.astype(np.uint8) * 255)
cv2.imshow('img2_mask', img2_mask.astype(np.uint8) * 255)
cv2.imshow('res1', res1)
cv2.imshow('res2', res2)
cv2.imshow('res', res)
cv2.waitKey(0)

pass